import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';

/* 路径方法 */
const pathResolver = (pathStr: string): string => {
	return resolve(__dirname, '.', pathStr);
};

// https://vitejs.dev/config/
export default defineConfig({
	resolve: {
		alias: {
			'@': pathResolver('./src'),
		},
	},
	server: {
		open: false,
		https: false,
		proxy: {
			'/api': {
				target: 'http://',
				changeOrigin: true,
				ws: false,
				secure: false,
				ignorePath: true,
			},
		},
	},
	build: {
		terserOptions: {
			compress: {
				keep_infinity: true,
				drop_console: true,
				drop_debugger: true,
			},
		},
		brotliSize: false,
		chunkSizeWarningLimit: 1200,
	},
	plugins: [vue()],
	css: {
		preprocessorOptions: {
			less: {
				modifyVars: {
					hack: `true; @import (reference) "@/styles/global/index.less";`,
				},
				javascriptEnabled: true,
			},
		},
	},
});
